<?php
	session_start();
	function calculateTableCssClass($handLog){
		//if it's a cash table roi > 0?
		$eventClass = ($handLog['tableStats']['roi'] < 0 ) ? 'lost' : 'won';
		//if its a STT how many players started
		//print_r($handLog['tableStats']);
		if(!empty($handLog['tableStats']['sttPosition'])){
			//how many runners?
			$runners = array_shift($handLog['hands']);
			//print_r($runners);
			$players = count($runners['Players']);
			$payoutPosition = 3;
			if($players <= 6){
				$payoutPosition = 2;
			}
			//was it a winner takes all?
			$eventClass = ($handLog['tableStats']['sttPosition'] <= $payoutPosition ) ? 'won' : 'lost';
			
		}
		return $eventClass;
	}


require('models/hand_analyser.php');
	$handAnalyser = new HandAnalyser();
		$handAnalyser->historyFolder = 'userfiles';
		$handAnalyser->userName = $_SESSION['username'];
		$handAnalyser->handDate = (isset($_REQUEST['date'])) ? $_REQUEST['date'] : date('Ymd');
		$handAnalyser->tableName = (isset($_REQUEST['table'])) ? stripslashes($_REQUEST['table']) : '';

		$handAnalyser->processHandFile();
		$handLog['hands'] = $handAnalyser->hands;
		$handLog['tableStats'] = $handAnalyser->tableStats;
		echo calculateTableCssClass($handLog);
		
?>